'use strict';
const path = require('path');
const smaiuacServiceBaseUrl = 'http://192.168.1.7:9001';
const webpack = require('webpack');
function resolve(dir) {
  return path.join(__dirname, dir);
}

const name = 'deepaint'; // page title

// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following methods:
// port = 9528 npm run dev OR npm run dev --port = 9528
const port = process.env.port || process.env.npm_config_port || 3000; // dev port

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  /**
   * You will need to set publicPath if you plan to deploy your site under a sub path,
   * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
   * then publicPath should be set to "/bar/".
   * In most cases please use '/' !!!
   * Detail: https://cli.vuejs.org/config/#publicpath
   */
  publicPath: '/', // 根路径
  outputDir: 'dist', // 打包的时候生成的一个文件名
  assetsDir: 'assets', // 静态资源目录(js,css,img,fonts)这些文件都可以写里面
  lintOnSave: process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true, // 启动项目后自动开启浏览器
    // hot: true,
    // clientLogLevel: 'warning',开启浏览器显示报错
    overlay: {// 是否开启协议名,如果开启会发出警告
      warnings: false,
      errors: true
    },
    proxy: {
      // 配置跨域
      [process.env.VUE_APP_BASE_API]: {// 配置跨域的名字
        target: smaiuacServiceBaseUrl, // 跨域的地址
        changeOrigin: true, // 是否跨域
        pathRewrite: {// 当前的名字
          ['^' + process.env.VUE_APP_BASE_API]: ''
        }
      }
    }
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    name: name,
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
    plugins: [
      new webpack.ProvidePlugin({
      $: 'jquery',
       jQuery: 'jquery',
       'windows.jQuery': 'jquery'
      })
       ]
  }
};
